home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / LAVIUPD3.ZIP / LAVI13.ZIP / GUN.RTN < prev    next >
Encoding:
Text File  |  1994-01-05  |  1.8 KB  |  39 lines

  1. ;  Makes Machine gun sounds over the speaker.
  2. ;  shots= numero de disparos
  3.  
  4. shots equ 60
  5.  
  6.         mov cx,shots
  7. machine_gun:
  8.         push    cx                      ; Save the current count
  9.         mov     dx,0140h                ; DX holds pitch
  10.         mov     bx,0100h                ; BX holds shot duration
  11.         in      al,061h                 ; Read the speaker port
  12.         and     al,11111100b            ; Turn off the speaker bit
  13. fire_shot:
  14.         xor     al,2                    ; Toggle the speaker bit
  15.         out     061h,al                 ; Write AL to speaker port
  16.         add     dx,09248h               ;
  17.         mov     cl,3                    ;
  18.         ror     dx,cl                   ; Figure out the delay time
  19.         mov     cx,dx                   ;
  20.         and     cx,01FFh                ;
  21.         or      cx,10                   ;
  22. shoot_pause:
  23.         loop    shoot_pause             ; Delay a bit
  24.         dec     bx                      ; Are we done with the shot?
  25.         jnz     fire_shot               ; If not, pulse the speaker
  26.         and     al,11111100b            ; Turn off the speaker bit
  27.         out     061h,al                 ; Write AL to speaker port
  28.         mov     bx,0002h                ; BX holds delay time (ticks)
  29.         xor     ah,ah                   ; Get time function
  30.         int     1Ah                     ; BIOS timer interrupt
  31.         add     bx,dx                   ; Add current time to delay
  32. shoot_delay:
  33.         int     1Ah                     ; Get the time again
  34.         cmp     dx,bx                   ; Are we done yet?
  35.         jne     shoot_delay             ; If not, keep checking
  36.         pop     cx                      ; Restore the count
  37.         loop    machine_gun             ; Do another shot
  38.         ret
  39.